perm filename TJ[E,ALS] blob
sn#224494 filedate 1976-07-09 generic text, type C, neo UTF8
COMMENT â VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 TJFILL
C00009 ENDMK
Câ;
;TJFILL
; Register Usage
Jâ12 ;Input column position
Kâ13 ;Currrent output tab field termination
; Q ;To index through TABTAO and TABTAB
; To skip TABs without counting them
TJ1TAB: MOVNI C,3
ADDM C,(P)
POPJ P,
; To exit from loop on any non-space
TJ1CH: AOS (P)
AOS (P)
POPJ P,
; Dispatch table to eat to next tab field
TJ1DSP: PUSHJ P,TJ1CR ;CR
PUSHJ P,TJ1TAB ;TAB (eaten)
JFCL ;Space (counted to TABEND)
PUSHJ P,TJ1CH ;Punctuation (exit from loop)
PUSHJ P,TJ1CH ;Closure " " "
PUSHJ P,TJ1CH ;Other character " " "
; To test if there is more than 1 space (indicating the end of an entry)
TJ2SP: MOVE T,A
ILDB C,T ;Sneak look at the next character
CAIE C,40
CAIN C,11
SKIPA
POPJ P, ;Single spaces are allowed in tab fields
TLNN F,TF1 ;Which pass?
JRST TJ2SP2
MOVEI C 40 ;It could have been a tab
IDPB C,D
IDPB C,D
AOS (P) ;For the extra instruction in second-pass loop
J2SP2: AOBJN G,.+1
AOBJP G,.+1
AOS J ;Only one character actually extracted
AOS (P)
AOS (P) ;Exit from loop
POPJ P,
; In-text dispatch table to look for a TAB or a CR
TJ2DSP: PUSHJ P,TJ2CR ;CR
PUSHJ P,TJ2TAB ;TAB
PUSHJ P,TJ2SP ;SP
JFCL
JFCL
JFCL
JU1E: MOVE G,TLMAR
TRNE F,REL ;No new par indent if 0
MOVE G,TPMAR
MOVEM G,JMARG ;Save as current margin for second pass
SUB G,TRMAR
JU1F: MOVNM G,JSIZE ;The expected size of new line less margin
SUBI G,1 ;Go 1 char. beyond on the first pass
HRLZS G
MOVEM A,ASAVE
SETZM JSCNT ;To count word separators
MOVE C,JCNT
MOVEM C,JCNTC
TRNE F,REL
TLNN F,TF2
JRST JU1G
; Special treatment if new par for TJ case
; Eat spaces only to TJPMARO
TJU1: SETZB Q,J
SKIPG TABTABO(Q) ;Are tab fields expected?
JRST JU2 ;No
MOVE TT,TPMARO
MOVEM TT,TABENO# ;For second pass use
JUMPE TT,JU1G
MOVE K,TPMAR
MOVEM K,TABEND# ;For second pass use
TJU2: MOVEI DSP,TJ1DSP
MOVSI H,JALL
TJU3: ILDB C,A ;Eat spaces and tabs to next tab field
TLNE H,JCTAB(C)
XCT @JCTAB(C)
CAMGE J,TABENO
AOJA J,TJU3
CAIN C,40 ;Did we find a character too soon?
TJU3A: ILDB C,A ;No, so get first char of new field
AOS J
TLNN F,TF1
JRST TJU4A
; Allow for spaces to be used on second pass
TJU4: CAILE K,(G)
AOBJN G,TJU4
HRRZM JWCOL ;Save in case no more tabs
AOBJP G,.+1 ;Allow for first char of new field
SKIPLE T,TABTAO(Q)
JRST TJU4A ;Can continue
AOS JSCNT ;Counts as a word break for justification
JRST JU1G ;Now complete normal first pass
TJU4A: HRRZM T,TABENO ;New input field end
HRRZ K,TABTAB(Q)
SUB K,TPMAR ;Remember that G is measured from TPMAR
AOS Q
MOVEI DSP,TJ2DSP
MOVSI H,JUSF
TJU4X: ILDB C,A
TDNE H,JCTAB(C)
XCT @JTAB(C)
AOS J ;Count input characters
AOBJN G,TJU4X
JRST TJU2
; Pad out new line with spaces to next tab field
TJU4A: PUSH P,C ;Save first char of field even if a space
MOVEI C,40
TJU4B: CAILE K,(G)
IDPB C,D
AOBJN G,TJU4B
JUMPL G,TJU4C
POP P,C
ADD G,[70000,,0] ;Last char must go on new line
JRST TJUX3
TJU4C: POP P,C
SKIPLE T,TABTAO(Q)
JRST TJU4D ;Get ready for normal 2nd pass line finish
ADD A.[70000,,0] ;Let normal routine handle this char.
JRST JU3X
TJU4D: IDPB C,D
AOBJN G,.+1
HRRZM T,TABENO ;New input field end
HRRZ K,TABTAB(Q)
SUB K,TPMAR ;Remember that G is measured from TPMAR
AOS Q
MOVEI DSP,TJ2DSP
MOVSI H,JUSF
TJU4Y: ILDB C,A
TDNE H,JCTAB(C)
XCT @JTAB(C)
AOS J ;Count input characters
IDPB C,D
AOBJN G,TJU4Y
JRST TJU2
; For introduction into main just routine ahead of JU4
TLNE F,TF2
JRST TJU1